package com.company.behavioral.command_pattern.demo2;

/**
 * @ClassName AddCommand
 * @Author tiezheng.han
 * @Date 2020/9/2 18:24
 **/
public class AddCommand extends AbstractCommand{

    private Adder adder = new Adder();

    private int value;

    @Override
    public int execute(int value) {
        this.value = value;
        return adder.add(value);
    }

    @Override
    public int undo() {
        return adder.add(-value);
    }
}
